<template>
  <min-dialog-box class="changeHost" v-if="ifShowChangeHost" :dialogData="dialogData" @submitBtnEvent="submit" @cancelBtnEvent="cancel"></min-dialog-box>
</template>

<script>
import { sendSock } from '@/utils/socketSend'

export default {
  name: 'changeHost',
  data () {
    return {
      // 是否显示转让主持人弹窗
      ifShowChangeHost: false
    }
  },
  props: {
    // 新的主持人的ID
    newHostID: Number
  },
  computed: {
    // 弹窗内容
    dialogData () {
      const newHostName = this.$store.state.chatInformation.userList[this.newHostID].user_name
      return {
        mainTips: ['设为主持人'],
        subTips: '确定将' + newHostName + '设置为主持人？',
        btnList: [{
          name: '确定',
          color: 'blue',
          type: 'submit'
        }, {
          name: '取消',
          color: 'white',
          type: 'cancel'
        }]
      }
    },
    // 会议ID
    cf_id () {
      return this.$store.state.conferenceRoom.cf_id
    }
  },
  methods: {
    // 切换弹窗的显示隐藏
    toggleShow () {
      this.ifShowChangeHost = !this.ifShowChangeHost
    },
    // 点击确定
    submit () {
      // 转让主持人
      sendSock({
        type: '4.1.25',
        body: {
          cf_id: this.cf_id,
          id: this.newHostID
        }
      })
      this.toggleShow()
    },
    // 点击取消
    cancel () {
      this.toggleShow()
    }
  }
}
</script>

<style scoped>

</style>
